#include "continueview.h"
#include "item/imageitem.h"
#include "recource.h"
#include <QLocale>

continueView::continueView(QWidget *parent) :
    QGraphicsView(parent)
{
    initItem();
}

continueView::~continueView()
{
    delete m_Scene;
}

void continueView::initItem()
{
    m_Scene = new QGraphicsScene(this);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setScene(m_Scene);
    m_Scene->setSceneRect(0.0, 0.0, 360.0, 640.0);
    setGeometry(0.0,0.0,360.0,640.0);

    m_bgItem = new ImageItem(*Recource::m_promptbgImage,
                             QRect(QPoint(0,0),Recource::m_promptbgImage->size()));
    m_bgItem->setPos(0.0,0.0);
    m_bgItem->setZValue(0.0);
    m_Scene->addItem(m_bgItem);

    switch(Recource::m_iLanguage)
    {
    case QLocale::Chinese:
    {
        m_mbgItem = new ImageItem(*Recource::m_continueCnMbgImage,
                                 QRect(QPoint(0,0),Recource::m_continueCnMbgImage->size()));
        m_backItem = new ImageItem(*Recource::m_continueCnBtnImage,
                                 QRect(QPoint(0,0),Recource::m_continueCnBtnImage->size()));
    }
        break;
//    case QLocale::HongKong:
    case 255:
    {
        m_mbgItem = new ImageItem(*Recource::m_continueHKMbgImage,
                                 QRect(QPoint(0,0),Recource::m_continueHKMbgImage->size()));
        m_backItem = new ImageItem(*Recource::m_continueHKBtnImage,
                                 QRect(QPoint(0,0),Recource::m_continueHKBtnImage->size()));
    }
        break;
    default:
    {
        m_mbgItem = new ImageItem(*Recource::m_continueEnMbgImage,
                                 QRect(QPoint(0,0),Recource::m_continueEnMbgImage->size()));
        m_backItem = new ImageItem(*Recource::m_continueEnBtnImage,
                                 QRect(QPoint(0,0),Recource::m_continueEnBtnImage->size()));
    }
        break;
    }


    m_mbgItem->setPos(0.0,159.0);
    m_mbgItem->setZValue(0.0);
    m_Scene->addItem(m_mbgItem);

    m_backItem->setPos(137.0,360.0);
    m_backItem->setZValue(1.0);
    m_backItem->setVisible(false);
    m_Scene->addItem(m_backItem);
}

void continueView::mouseReleaseEvent(QMouseEvent *event)
{
    m_backItem->setVisible(false);
    if(m_backItem->isUnderMouse())
    {
        emit back();
    }
}

void continueView::mousePressEvent(QMouseEvent *event)
{
    if(m_backItem->isUnderMouse())
    {
        m_backItem->setVisible(true);
    }
}
